package com.hk.wms.wmsssoserver.controller;

import com.hk.wms.common.common.JwtUtils;
import com.hk.wms.common.common.R;
import com.hk.wms.common.entity.User;
import com.hk.wms.wmsssoserver.service.Memberservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@CrossOrigin
public class MemberController {
    @Autowired
    Memberservice memberService;
    @GetMapping("/login2")
    @ResponseBody
    public R loginUser( User user){
        String token=memberService.login(user);
        return R.ok().data("token",token);
    }
    @GetMapping("/userinfo")
    public R getUserInfo(HttpServletRequest request){
      String username=  JwtUtils.getMemberIdByJwtToken(request);
      return R.ok().data("username",username);
    }
}
